<template>
  <div class="resource">
    <!-- <div class='job-banner ct'>
      <div class="banner-text">
        <div class="c-new-title">
          资源共享
        </div>
        <div class="c-new-text">
          “站院联建”农技推广服务平台
        </div>
      </div>
    </div> -->
    <div class="s-content ct" >
      <div class="s-search">
        <el-input
          v-model="input2"
          class="s-input"
        >
          <template #append>
            <div @click="search1">搜索</div>
          </template>
        </el-input>
      </div>
      <div class="s-detal item-content">
        <div class="new-info">
          <div class="info-item" @click="goDetail(item)" v-for="item in works.list">
            <div class="info-i-t">
              <div class="i-l">{{ item.bulletinTitle }}</div>
              <div class="i-r">
                {{ item.createdTime }}
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="item-page">
        <el-pagination
            :current-page="works.page"
            :page-size="15"
            background
            layout="prev, pager, next, jumper"
            prev-text="上一页"
            next-text="下一页"
            :total="works.total"
            @current-change="getPageInformation"
        />
      </div>
    </div>
  </div>
</template>  
<script setup>
import { pageBulletin } from '@/api/home';
import { useRouter } from 'vue-router';

import { computed, reactive, ref } from 'vue'

  const router = useRouter();
  const yardId = computed(() => router?.currentRoute?.value?.query.yardId)

const input2 = ref('');

const search1 = () => {
  works.title = input2.value;
  getPageInformation(0);
}

const works = reactive({
    list: [],
    total: 0,
    page: 1,
    title: ''
  });


  const getPageInformation = async(pageNum=1) => {
     const params = {
      params: {
        status: true,
        courtyardId: yardId.value,
      },
      page: {
        pageSize: 10,
        pageNum: 1,
      }
    }
    const ret = await pageBulletin(params)
    // notices.value = ret?.data?.list || [];

    // const ret = await pageInformation(params)
    works.list = ret?.data?.list || [];
    works.total = ret?.data?.total;
    works.page = pageNum;
  }


  getPageInformation()
  

const goDetail = (item) => {
//   router.push(`/job/jobdetail/${item.informationId}?type=information`)
  router.push('/job/jobdetail/'+item.bulletinId+'?type=notice')
}

</script>
<style lang="scss" scoped>
.resource {
  width: 100%;
  display: flex;
  flex-direction: column;
  color: #777;
  min-height: 900px;
  overflow: hidden;
  flex: 1;
  background: #f8f8f8 url('../../assets/job/6.png') no-repeat 0 200px;
  .job-banner {
    width: 100%;
    height: 280px;
    background: url(../../assets/zygx/1.png) no-repeat center center / cover;
    padding: 0 10%;
    display: flex;
    align-items: center;
    color: #fff;
    .banner-text {
      padding-left: 30px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      position: relative;
      &::after {
        position: absolute;
        left: 0;
        top: 12px;
        height: 84%;
        width: 4px;
        background-color: #fff;
        content: ''
      }
      .c-new-title {
        font-weight: 700;
        font-size: 50px;
      }
      .c-new-text {
        font-size: 30px;
      }
    }
  }
  .s-content {
    display: flex;
    flex-direction: column;
    background: #f8f8f8 url('../../assets/job/6.png') no-repeat 0 200px;
    min-height: 1000px;
    width: 100%;
    padding: 0 10%;
    margin-top: 40px;
    font-size: 24px;
  }
  .s-search {
    display: flex;
    align-items: center;
    :deep(.s-input) {
      font-size: 20px;
      height: 50px;
      width: 50%;
      .el-input__wrapper {
        background-color: #fff;
        box-shadow: none;
      }
      .el-input-group__append {
        color: #fff;
        background-color: #068043;
        height: 100%;
        padding: 0 30px;
        border-radius: 5px;
        cursor: pointer;
      }
    }
    .s-input-ti {
      color: #fff;
      background-color: #068043;
      padding: 0 30px;
      border-radius: 5px;
      height: 50px;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-left: 30px;
      cursor: pointer;
    }
  }
  .s-detal {
    margin-top: 30px;
    flex: 1;
    overflow: hidden;
    background-color: #fff;
  }
  .item-content {
    padding-top: 5px;
    display: flex;
    flex-direction: column;
    .new-info {
      flex: 1;
      background-color: #fff;
      padding: 20px 40px;
      overflow: hidden;
      color: #777;
      .info-item {
        border-bottom: 2px solid #e5e5e5;
        cursor: pointer;
        &:last-child{
          border-bottom: 0 none;
        }
      }
      .info-i-t {
        font-size: 24px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 15px 0;
        .i-l {
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
        }
        .i-r {
          margin-left: 40px;
        }
      }
    }
  }
  .item-page {
      height: 160px;
      display: flex;
      align-items: center;
      justify-content: center;
      :deep(.el-pagination) {
        button, li {
          background-color: transparent;
          width: 50px;
          height: 50px;
          border: 2px solid #e5e5e5;
          border-radius: 5px;
          color: #777;
          font-size: 24px;
          font-weight: normal;
          margin-right: 30px;
        }
        button {
          border: 0 none;
        }
        .el-pagination__jump {
          color: #777;
          font-size: 26px;
        }
        .el-pagination__editor {
          min-width: 50px;
          min-height: 50px;
          font-size: 24px;
        }
        .el-input__wrapper {
          padding: 0;
        }
        .el-input__inner {
          color: #777 !important;
        }
      }
    }

}
</style>